
import { _decorator, Component, Node } from 'cc';
const { ccclass, property } = _decorator;
import * as cc from "cc";
import { resourcesMgr } from '../../framework/loader/ResourcesMgr';

/**
 * Predefined variables
 * Name = Item
 * DateTime = Fri Mar 18 2022 08:38:15 GMT+0800 (中国标准时间)
 * Author = 272493431
 * FileBasename = Item.ts
 * FileBasenameNoExtension = Item
 * URL = db://assets/scripts/scene/BagDemo/Item.ts
 * ManualUrl = https://docs.cocos.com/creator/3.4/manual/zh/
 *
 */
 
@ccclass('Item')
export class Item {
    
    node: cc.Node;
    parent: cc.Node

    isReady = false;

    data: BagData;

    constructor(parent: cc.Node){
        this.parent = parent;
    }

    onCtor(){
        resourcesMgr.load(this,"prefabs/Item",cc.Prefab,(err,prefab)=>{
            if(err){
                return;
            }
            
            this.node = cc.instantiate(prefab);
            this.node.parent = this.parent;
            this.isReady = true;
        });
    }

    updateData(_data: BagData){
        this.data = _data;
        // 如果打开 JsonObserve 下的emitTerminal 则可以实时通知到
    }



}
